package com.example.exercises;

import com.alibaba.fastjson.JSON;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class FindNumsAppearOnce {
    /**
     * 代码中的类名、方法名、参数名已经指定，请勿修改，直接返回方法规定的值即可
     *
     * @param array int整型一维数组
     * @return int整型一维数组
     */

    public static void main(String[] args) {
        FindNumsAppearOnce solution33 = new FindNumsAppearOnce();
        int c[] = {4, 5, 6};
        System.out.println(JSON.toJSONString(solution33.FindNumsAppearOnce(c)));
        int a = 2;
        double sqrt = Math.sqrt(a);
        System.out.println(sqrt % 1 == 0);
    }

    public int[] FindNumsAppearOnce(int[] array) {
        // write code here
        Arrays.sort(array);
        List<Integer> list = new ArrayList<>();


        int count = 0;
        int n = array.length;
        for (int i = 1; i < n; i++) {
            if (array[i - 1] == array[i]) {
                count++;
            }
            if (array[i - 1] != array[i] && count == 0) {
                count = 0;
                list.add(array[i - 1]);
            }
        }
        int[] a = new int[list.size()];
        for (int i = 0; i < list.size(); i++) {
            a[i] = list.get(i);
        }
        return a;
    }
}

